﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using FirebirdSql.Data.FirebirdClient;
using System.Configuration;

/// <summary>
/// Сводное описание для DbConn
/// </summary>
public class DbConn : IDisposable
{
    protected FbConnection _FbDB;
    protected SqlConnection _DispDB;

    public FbConnection FbDB
    {
        get { return _FbDB; }
    }

    public SqlConnection DispDB
    {
        get { return _DispDB; }
    }

	public DbConn()
    {
        #region Firebird connection
        //FbConnectionStringBuilder csb = new FbConnectionStringBuilder();
        //csb.UserID = "SYSDBA";
        //csb.Password = "masterkey";
        //csb.Database = @"localhost:f:\base\DEZ.FDB";

        //_FbDB = new FbConnection(csb.ToString());

        string cns = ConfigurationManager.ConnectionStrings["ConnectionStringDez"].ConnectionString;
        _FbDB = new FbConnection(cns);
        #endregion

        #region SqlConnection
        string cnsD = ConfigurationManager.ConnectionStrings["DispatcherWebAppConnectionString"].ConnectionString;
        _DispDB = new SqlConnection(cnsD);
        #endregion
    }
    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }
    protected virtual void Dispose(bool disposing)
    {
        if (disposing)
        {
            if (_FbDB != null)
            {
                _FbDB.Dispose();
                _FbDB = null;
            }
            if (_DispDB != null)
            {
                _DispDB.Dispose();
                _DispDB = null;
            }
        }
    }
    ~DbConn()
    {
        Dispose(false);
    }
}